jQuery(document).ready(function() {

    /*
        Background slideshow
    */
    $.backstretch(["./images/2.jpg", "./images/3.jpg"], { duration: 3000, fade: 750 });
    /*
        表单校验
    */
    $('.register form').submit(function() {
        var userName = $(this).find('input#txtUserName').val();
        var password = $(this).find('input#txtPassword').val();
        var confirmPassword = $(this).find('input#txtConfirmPassword').val();
        var sex = $(this).find('input[name="ridsex"]:checked').val();
        var education = $(this).find('input[name="rideducation"]:checked').val();
        var desc = $('txtDesc').val();
        if (password == '') {
            $(this).find("label[for='txtPassword']").append("<span style='display:none' class='red'> - 请输入你的密码.</span>");
            $(this).find("label[for='txtPassword'] span").fadeIn('medium');
            $(this).find('input#txtPassword').focus();
            $(this).find('input#txtPassword').val('');
            return false;
        }
        if (password !== confirmPassword) {
            $(this).find("label[for='txtConfirmPassword']").append("<span style='display:none' class='red'> - 两次密码输入不一致，请重新输入.</span>");
            $(this).find("label[for='txtConfirmPassword'] span").fadeIn('medium');
            $(this).find('input#txtConfirmPassword').focus();
            $(this).find('input#txtConfirmPassword').val('');
            return false;
        }
        if (desc == '') {
            $(this).find("label[for='txtDesc']").append("<span style='display:none' class='red'> - 请输入自我介绍.</span>");
            $(this).find("label[for='txtDesc'] span").fadeIn('medium');
            $('txtDesc').focus();
            $('txtDesc').val('');
            return false;
        }
        var content = "用户名：" + userName + "," + "密码：" + password + "," + "性别：" + sex + "," + "学历：" + education + "," + "自我介绍：" + desc;
        alert(content);
    });

    $("#txtUserName").bind("blur", function() {
        if ($(this).val() !== "admin") {
            alert("输入错误");
            $("#txtUserName").focus();
        }
    })

});